package com.darren.archive.dao.impl;

import com.darren.archive.dao.CityDao;
import com.darren.archive.entity.City;
import com.darren.framework.dao.impl.GenericDaoImpl;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public class CityDaoImpl extends GenericDaoImpl<City, Long> implements CityDao {

    @Override
    public List<City> findCitiesByProvinceCode(String provinceCode) {
        Session session = sessionFactory.getCurrentSession();
        Query<City> query = session.createQuery(" from City where provinceCode =:provinceCode ",City.class);
        query.setParameter("provinceCode", provinceCode);
        return query.list();
    }
}